# 使用for实现循环和遍历

# 计算y=2*|x|+5
# 结合条件与循环实现
def math_calc(x):
    y = [v * 2 + 5 if v > 0 else -v * 2 + 5 for v in x]
    print(y)


def fruits():
    """使用for-in语法遍历集合"""

    fruit_list = ['apple', 'banana', 'cherry', 'durian']
    for fruit in fruit_list:
        print(fruit)


if __name__ == '__main__':
    # 使用for item in : 语法,可以遍历列表和集合等等
    # nums = [1, 2, 3, 4, 5]
    # for n in nums:
    #     print(n)

    # 结合条件与循环
    # math_calc([1, -1, 2, -2, 3, 6, -100])

    fruits()
